package com.slmxz.tms.biz.controller;

import com.slmxz.tms.biz.model.dto.OrderDispatchDTO;
import com.slmxz.tms.biz.service.OrderDispatchService;
import com.slmxz.tms.common.annotation.Log;
import com.slmxz.tms.common.enums.LogModuleEnum;
import com.slmxz.tms.common.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单调度运输前端控制层
 *
 * @author sunyao
 *@Date 2025-07-16 21:13
 */
@Tag(name = "订单调度运输接口")
@RestController
@RequestMapping("/biz/orderDispatch")
@RequiredArgsConstructor
public class OrderDispatchController  {

    private final OrderDispatchService orderDispatchService;


    @Operation(summary = "新增订单调度运输")
    @PostMapping("/save")
    @PreAuthorize("@ss.hasPerm('biz:orderDispatch:add')")
    @Log(value = "订单调度", module = LogModuleEnum.TRANSIT)
    public Result<Void> saveOrderDispatch(@RequestBody OrderDispatchDTO orderDispatch) throws Exception {
        this.orderDispatchService.dispatchOrder(orderDispatch);
        return Result.success();
    }



    @Operation(summary = "撤销订单调度运输")
    @PostMapping("/cancel")
    @Log(value = "撤销订单调度", module = LogModuleEnum.TRANSIT)
    @PreAuthorize("@ss.hasPerm('biz:orderDispatch:add')")
    public Result<Void> cancenOrderDispatchs(@RequestBody OrderDispatchDTO orderDispatch) throws Exception {
        this.orderDispatchService.cancelDispatchOrder(orderDispatch);
        return Result.success();
    }
}
